package com.lc.utils;


import com.cnpc.framework.base.utils.HttpClient;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 下雨不带伞 on 2018/11/16.
 */
public class BaiduPostUtils {

    public static String BAIDU_URL_PROFIX = "http://yingyan.baidu.com/api/v3";
    public static String post(String url, Map<String, String> params){
        url = BAIDU_URL_PROFIX+url;
        params.put("service_id","203636");
        params.put("ak","T8BKiy9DrT2afNAefzi32zriGoYtXxjj");
        return HttpClient.httpPost(url,params);
    }

    public static <T> T  post(String url, Map<String, Object> params, Class<T> clazz)throws Exception{
        url = BAIDU_URL_PROFIX+url;
        params.put("service_id","203636");
        params.put("ak","T8BKiy9DrT2afNAefzi32zriGoYtXxjj");
        return HttpClient.restTemplatePost(url,params,clazz);
    }

    public static <T> T  list(String url, Class<T> clazz)throws Exception{
        url = BAIDU_URL_PROFIX+url;
        Map<String, Object> params = new HashMap<>();
        params.put("service_id","203636");
        params.put("ak","T8BKiy9DrT2afNAefzi32zriGoYtXxjj");
        return HttpClient.restTemplateGet(url,params,clazz);
    }


    public static <T> T  get(String url, Map<String, Object> params, Class<T> clazz) throws Exception{
        url = BAIDU_URL_PROFIX+url;
        params.put("service_id","203636");
        params.put("ak","T8BKiy9DrT2afNAefzi32zriGoYtXxjj");
        return HttpClient.restTemplateGet(url,params,clazz);
    }

    public static <T> T  getV1(String url, Map<String, Object> params, Class<T> clazz) throws Exception{
        params.put("service_id","203636");
        params.put("ak","T8BKiy9DrT2afNAefzi32zriGoYtXxjj");
        return HttpClient.restTemplateGet(url,params,clazz);
    }



}
